package com.cloudkinto.service.consumer.vo.orderSyncRecord;

import com.cloudkinto.service.platform.sync.vo.SyncRecordItemReq;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PlatformOrderSyncRecordReq {
    private Long id;
     //* 同步状态 等待同步 同步中 同步成功 同步失败
    private Integer syncStatus;

    private Date finishTime;
    private Date executeTime;

    private String failReason;
    private Integer orderCount;

    private Date beginTime;

    private Date endTime;

    private List<SyncRecordItemReq> syncItems;


    public String getFailReason() {
        if (StringUtils.isNotBlank(failReason) && failReason.length() > 150) {
            return failReason.substring(0, 150);
        }
        return failReason;
    }

    public PlatformOrderSyncRecordReq(Long id, Integer syncStatus, Date finishTime, Date executeTime) {
        this.id = id;
        this.syncStatus = syncStatus;
        this.finishTime = finishTime;
        this.executeTime = executeTime;
    }

    public PlatformOrderSyncRecordReq(Long id, Integer syncStatus, Date finishTime, Date executeTime, String failReason, Integer orderCount) {
        this.id = id;
        this.syncStatus = syncStatus;
        this.finishTime = finishTime;
        this.executeTime = executeTime;
        this.failReason = failReason;
        this.orderCount = orderCount;
    }


    public PlatformOrderSyncRecordReq(Long id, Integer syncStatus, Date finishTime, Date executeTime, String failReason, Integer orderCount, List<SyncRecordItemReq> syncItems) {
        this.id = id;
        this.syncStatus = syncStatus;
        this.finishTime = finishTime;
        this.executeTime = executeTime;
        this.failReason = failReason;
        this.orderCount = orderCount;
        this.syncItems = syncItems;
    }

    public PlatformOrderSyncRecordReq(Long id, Integer syncStatus, Date executeTime, Date beginTime, Date endTime) {
        this.id = id;
        this.syncStatus = syncStatus;
        this.executeTime = executeTime;
        this.beginTime = beginTime;
        this.endTime = endTime;
    }
}
